<?php
require_once(dirname(__FILE__)."/../inc/common.php");
/*******************************************************************************************
'*******************************************************************************************/
if (paramset==0 || runMode=="forgedStatic"){
	$id = replaceStr(QUERY_STRING, fileSuffix, "");
}else{
	$id = getForm(paramid,"both");
}

if (empty($id)) {
	echoSaveStr("null");exit();
} else {
	if(!is_numeric($id)) { echoSaveStr("safe");exit(); } else { $id=intval($id); }
}

echoContent($id);

function echoContent($vId) {
	global $t1;
	$row = DB::fetch_first("SELECT m_id,m_type,m_name,m_state,m_pic,m_hit,m_actor,m_des,m_topic,m_color,m_addtime,m_publishyear,m_publisharea,m_commend,m_note,m_keyword ,m_digg,m_tread,m_playdata,m_downdata,m_enname,m_datetime,m_director,m_lang,m_score,m_count FROM ".DB::table('data')." WHERE m_recycle=0 AND m_id='$vId'");
	if (!is_array($row)) { OutNotFound("content");}
	$vType = $row['m_type'];$venname = $row['m_enname'];$vdatetime = $row['m_datetime'];
	if (iscache == '1'){
       checkCourt($vType);
    }
	$y = explode(",",getTypeNameTemplateArrayOnCache($vType));
	$z = ifthen(empty($y[4]),"content.html",$y[4]);$x = DJCMS_TEMPLATE.$z;
	if (strpos(" ,".getHideTypeIDS().",",",".$vType.",") > 0) { OutNotFound("content");}
	$contentLink = getContentLink($vType,$vId,$venname,$vdatetime,"link");
	$typeText = getTypeTextOnCache($vType);
	djcms::$currentTypeId = $vType;
	$typeFlag = "parse_content_" ;
	$cacheName = $typeFlag.$vType;
	if (cacheStart == 1) {
		if (!djcms::$content = memory('get', $cacheName)) {
            parseContentPart($x);memory('set', $cacheName, djcms::$content);
        }
	} else {
		parseContentPart($x);
	}
	djcms::paresPreNextVideo($vId, "content", $vType);
	djcms::parseVideo($row);
	$content = replaceStr(djcms::$content,"{playpage:id}",$row['m_id']);
	$content = replaceStr($content,"{playpage:desktopurl}","/".sitePath."desktop.php?name={playpage:encodename}&url=".urlencode($contentLink));
	$content = replaceStr($content,"{playpage:encodename}",urlencode($row['m_name']));
	$content = replaceStr($content,"{playpage:lang}",$row['m_lang']);
	$content = replaceStr($content,"{playpage:nolinkkeywords}",$row['m_keyword']);
	if (isExistStr($content,"{playpage:keywords}")) $content = replaceStr($content,"{playpage:keywords}",getKeywordsList($row['m_keyword'],"&nbsp;&nbsp;"));
	if (!empty($row['m_pic'])) {
		if (isExistStr($row['m_pic'], '://')) {
		    $content = replaceStr($content,"{playpage:pic}",$row['m_pic']);
		} else {
		    $content = replaceStr($content,"{playpage:pic}","/".sitePath.$row['m_pic']);
		}
	} else {
		$content = replaceStr($content,"{playpage:pic}","/".sitePath."pic/nopic.gif");
	}
	$content = replaceStr($content,"{playpage:director}",getKeywordsList($row['m_director'],"&nbsp;&nbsp;"));
	$content = replaceStr($content,"{playpage:publishtime}",$row['m_publishyear']);
	$content = replaceStr($content,"{playpage:publisharea}",$row['m_publisharea']);
	$content = replaceStr($content,"{playpage:state}",$row['m_state']);
	$content = replaceStr($content,"{playpage:diggnum}",$row['m_digg']);
	$content = replaceStr($content,"{playpage:treadnum}",$row['m_tread']);
	$content = replaceStr($content,"{playpage:scorenum}",$row['m_count']);
	$content = replaceStr($content,"{playpage:score}",$row['m_score']);
	$content = replaceStr($content,"{playpage:commend}",$row['m_commend']);
	$content = replaceStr($content,"{playpage:link}",$contentLink);
	$content = replaceStr($content,"{playpage:url}","http://".siteUrl.$contentLink);
	$content = replaceStr($content,"{playpage:textlink}",$typeText."&nbsp;&nbsp;&raquo;&nbsp;&nbsp;".$row['m_name']);
	$playLink=getPlayLink2($vType,$row['m_id'],$row['m_addtime'],$row['m_enname'],0,0);
	if (isAlertWin==1){ $playLink="javascript:openWin('".$playLink."',".($alertWinW+10).",".($alertWinH+55).",250,100,1)";}
	djcms::$content = replaceStr($content,"{playpage:playlink}",$playLink);
	djcms::parsePlayList($vType,$vId,$venname,$vdatetime,$row['m_playdata'],"play");
	djcms::parsePlayList($vType,$vId,$venname,$vdatetime,$row['m_downdata'],"down");
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{yh:runinfo}",getRunTime($t1)) ;
}

function parseContentPart($x) {
	djcms::$content=loadFile($x);
	djcms::parsePlayPageSpecial();
	djcms::parseTopAndFoot();
	djcms::parseSelf();
	djcms::parseGlobal();
	$typename = explode(",", getTypeNameTemplateArrayOnCache(intval(djcms::$currentTypeId)));
	djcms::$content = replaceStr(replaceStr(djcms::$content,"{yh:currenttypeid}",djcms::$currentTypeId),"{playpage:typeid}",djcms::$currentTypeId);
	if (isExistStr(djcms::$content,"{playpage:typename}")) djcms::$content = replaceStr(djcms::$content,"{playpage:typename}",$typename[0]);
    if (isExistStr(djcms::$content,"{playpage:typelink}")) djcms::$content = replaceStr(djcms::$content,"{playpage:typelink}",getTypeLink(djcms::$currentTypeId));
	if (isExistStr(djcms::$content,"{playpage:upid}")) djcms::$content = replaceStr(djcms::$content,"{playpage:upid}",getTypeUpid(djcms::$currentTypeId));
	djcms::parseMenuList("");
	djcms::parseNewsList();
	djcms::parseAreaList();
	djcms::parseVideoList();
	djcms::parseTopicList();
}
?>
